var FormAddContactValidation = function () {

    var handleValidation1 = function () {
        // for more info visit the official plugin documentation: 
        // http://docs.jquery.com/Plugins/Validation

        var form1 = $('#form_edit_user');
        var error1 = $('.alert-danger', form1);
        var success1 = $('.alert-success', form1);

        form1.validate({
            errorElement: 'span', //default input error message container
            errorClass: 'help-block', // default input error message class
            focusInvalid: false, // do not focus the last invalid input
            ignore: "",
            rules: {
                first_name: {
                    minlength: 2,
                    required: true,
                },
                last_name: {
                    minlength: 2,
                    required: true,
                },
                username: {
                    minlength: 2,
                    required: true,
                },
            },
            messages: {
                first_name: "Bắt buộc phải nhập.",
                last_name: "Bắt buộc phải nhập.",
                username: {
                    required: "Bắt buộc phải nhập.",
                    minlength: "Nhập tối thiểu 2 ký tự",
          },
            },
            invalidHandler: function (event, validator) { //display error alert on form submit              
                success1.hide();
                error1.show();
                App.scrollTo(error1, -200);
            },
            highlight: function (element) { // hightlight error inputs
                $(element)
                        .closest('.form-group').addClass('has-error'); // set error class to the control group
            },
            unhighlight: function (element) { // revert the change done by hightlight
                $(element)
                        .closest('.form-group').removeClass('has-error'); // set error class to the control group
            },
            success: function (label) {
                label
                        .closest('.form-group').removeClass('has-error'); // set success class to the control group
            },
            submitHandler: function (form) {
                success1.show();
                error1.hide();
                form.submit();


            }
        });

    }


    return {
        //main function to initiate the module
        init: function () {


            handleValidation1();



        }

    };

}();



    